From e05a02e20a8a4d2095d8160d30c35a06592a0e95 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Wed, 18 Jan 2006 01:15:22 +0000 Subject: [PATCH] webif-changes: * removed extra files display-dhcp.awk, display-hosts.awk, moved the code into hosts.sh * moved the wds list from wireless-config to wireless-advanced ("Advanced Wireless") * added wireless mac filter editor SVN-Revision: 3009 --- .../files/usr/lib/webif/display-dhcp.awk | 21 ------ .../files/usr/lib/webif/display-hosts.awk | 37 ----------- .../webif/files/usr/lib/webif/form.awk | 11 +++- .../webif/files/usr/lib/webif/validate.awk | 2 +- .../webif/files/www/cgi-bin/webif/hosts.sh | 65 ++++++++++++++++++- .../www/cgi-bin/webif/wireless-advanced.sh | 65 +++++++++++++++++++ .../www/cgi-bin/webif/wireless-config.sh | 34 ++++------ openwrt/package/webif/files/www/webif.js | 5 ++ 8 files changed, 153 insertions(+), 87 deletions(-) delete mode 100644 openwrt/package/webif/files/usr/lib/webif/display-dhcp.awk delete mode 100644 openwrt/package/webif/files/usr/lib/webif/display-hosts.awk create mode 100755 openwrt/package/webif/files/www/cgi-bin/webif/wireless-advanced.sh diff --git a/openwrt/package/webif/files/usr/lib/webif/display-dhcp.awk b/openwrt/package/webif/files/usr/lib/webif/display-dhcp.awk deleted file mode 100644 index 28c5067359..0000000000 --- a/openwrt/package/webif/files/usr/lib/webif/display-dhcp.awk +++ /dev/null @@ -1,21 +0,0 @@ -BEGIN { - FS="[ \t]" - print "
" - start_form("Static IP addresses (for DHCP)") - print "" - print "" -} - -# only for valid MAC addresses -($1 ~ /^[0-9A-Fa-f][0-9A-Fa-f]:[0-9A-Fa-f][0-9A-Fa-f]:[0-9A-Fa-f][0-9A-Fa-f]:[0-9A-Fa-f][0-9A-Fa-f]:[0-9A-Fa-f][0-9A-Fa-f]:[0-9A-Fa-f][0-9A-Fa-f]$/) { - gsub(/#.*$/, ""); - print "" -} - -END { - print "" - print "
MAC addressIP
" $1 "" $2 "Remove
" - print "
" - end_form(); -} - diff --git a/openwrt/package/webif/files/usr/lib/webif/display-hosts.awk b/openwrt/package/webif/files/usr/lib/webif/display-hosts.awk deleted file mode 100644 index db522a3020..0000000000 --- a/openwrt/package/webif/files/usr/lib/webif/display-hosts.awk +++ /dev/null @@ -1,37 +0,0 @@ -BEGIN { - FS="[ \t]" - start_form("Hostnames") - print "" - print "" - print "" -} - -# only for valid IPv4 addresses -($1 ~ /^[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*$/) { - gsub(/#.*$/, ""); - output = "" - names_found = 0 - n = split($0, names, "[ \t]") - first = 1 - for (i = 2; i <= n; i++) { - if (names[i] != "") { - if (first != 1) output = output "" - output = output "" - first = 0 - names_found++ - } - } - if (names_found > 0) { - print "" output - print "" - } -} - -END { - print "" - print "" - print "" - print "
IPHostname

" names[i] "Remove
" $1 "

" - end_form() -} - diff --git a/openwrt/package/webif/files/usr/lib/webif/form.awk b/openwrt/package/webif/files/usr/lib/webif/form.awk index 7f43d4f872..5c5cf52c83 100644 --- a/openwrt/package/webif/files/usr/lib/webif/form.awk +++ b/openwrt/package/webif/files/usr/lib/webif/form.awk @@ -20,7 +20,7 @@ $1 ~ /^onchange/ { ($1 != "") && ($1 !~ /^option/) && (select_open == 1) { select_open = 0 - print "" + printf "" } $1 ~ /^start_form/ { if ($3 != "") field_opts=" id=\"" $3 "\"" @@ -36,7 +36,10 @@ $1 ~ /^field/ { if ($3 != "") field_opts=" id=\"" $3 "\"" else field_opts="" if ($4 == "hidden") field_opts = field_opts " style=\"display: none\"" - print "" $2 "" + print "" + if ($2 != "") print "" $2 "" + else print "" + field_open=1 } $1 ~ /^checkbox/ { @@ -63,7 +66,7 @@ $1 ~ /^select/ { else option_selected="" if ($3 != "") option_title = $3 else option_title = $2 - print "" option_title "" + print "" option_title "  " } ($1 ~ /^listedit/) { n = split($4 " ", items, " ") @@ -72,6 +75,8 @@ $1 ~ /^select/ { } print "" } +$1 ~ /^caption/ { print "" $2 "" } +$1 ~ /^string/ { print $2 } $1 ~ /^text/ { print "" $4 } $1 ~ /^password/ { print "" $4 } $1 ~ /^submit/ { print "" } diff --git a/openwrt/package/webif/files/usr/lib/webif/validate.awk b/openwrt/package/webif/files/usr/lib/webif/validate.awk index 0aca1b0c87..517ce647cb 100644 --- a/openwrt/package/webif/files/usr/lib/webif/validate.awk +++ b/openwrt/package/webif/files/usr/lib/webif/validate.awk @@ -76,7 +76,7 @@ $1 == "wpapsk" { valid = 0 verr = "String too long" } - if (length(value) < 8) { + if ((length(value) != 0) && (length(value) < 8)) { valid = 0 verr = "String too short" } diff --git a/openwrt/package/webif/files/www/cgi-bin/webif/hosts.sh b/openwrt/package/webif/files/www/cgi-bin/webif/hosts.sh index ff7d9dcbf0..fd268eb9d6 100755 --- a/openwrt/package/webif/files/www/cgi-bin/webif/hosts.sh +++ b/openwrt/package/webif/files/www/cgi-bin/webif/hosts.sh @@ -84,14 +84,73 @@ header "Network" "Hosts" "Configured hosts" '' # Hosts in /etc/hosts awk -v "url=$SCRIPT_NAME" \ -v "ip=$FORM_host_ip" \ - -v "name=$FORM_host_name" -f /usr/lib/webif/common.awk -f /usr/lib/webif/display-hosts.awk $HOSTS_FILE + -v "name=$FORM_host_name" -f /usr/lib/webif/common.awk -f - $HOSTS_FILE <" + print "IPHostname" + print "
" +} + +# only for valid IPv4 addresses +(\$1 ~ /^[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*$/) { + gsub(/#.*$/, ""); + output = "" + names_found = 0 + n = split(\$0, names, "[ \\t]") + first = 1 + for (i = 2; i <= n; i++) { + if (names[i] != "") { + if (first != 1) output = output "" + output = output "" names[i] "Remove" + first = 0 + names_found++ + } + } + if (names_found > 0) { + print "" \$1 "" output + print "
" + } +} + +END { + print "
" + print "" + print "
" + print "" + end_form() +} +EOF # Static DHCP mappings (/etc/ethers) awk -v "url=$SCRIPT_NAME" \ -v "mac=$FORM_dhcp_mac" \ - -v "ip=$FORM_dhcp_ip" -f /usr/lib/webif/common.awk -f /usr/lib/webif/display-dhcp.awk $ETHERS_FILE + -v "ip=$FORM_dhcp_ip" -f /usr/lib/webif/common.awk -f - $ETHERS_FILE <" + start_form("Static IP addresses (for DHCP)") + print "" + print "" +} + +# only for valid MAC addresses +(\$1 ~ /^[0-9A-Fa-f][0-9A-Fa-f]:[0-9A-Fa-f][0-9A-Fa-f]:[0-9A-Fa-f][0-9A-Fa-f]:[0-9A-Fa-f][0-9A-Fa-f]:[0-9A-Fa-f][0-9A-Fa-f]:[0-9A-Fa-f][0-9A-Fa-f]$/) { + gsub(/#.*$/, ""); + print "" +} + +END { + print "" + print "
MAC addressIP
" \$1 "" \$2 "Remove
" + print "" + end_form(); +} +EOF footer ?> diff --git a/openwrt/package/webif/files/www/cgi-bin/webif/wireless-advanced.sh b/openwrt/package/webif/files/www/cgi-bin/webif/wireless-advanced.sh new file mode 100755 index 0000000000..c9a4b9e9ea --- /dev/null +++ b/openwrt/package/webif/files/www/cgi-bin/webif/wireless-advanced.sh @@ -0,0 +1,65 @@ +#!/usr/bin/haserl + + +
+EOF + +display_form < + + + + diff --git a/openwrt/package/webif/files/www/cgi-bin/webif/wireless-config.sh b/openwrt/package/webif/files/www/cgi-bin/webif/wireless-config.sh index d93b077c30..cc1f6b16b4 100755 --- a/openwrt/package/webif/files/www/cgi-bin/webif/wireless-config.sh +++ b/openwrt/package/webif/files/www/cgi-bin/webif/wireless-config.sh @@ -3,14 +3,6 @@ . /usr/lib/webif/webif.sh load_settings "wireless" -FORM_wds="${wl0_wds:-$(nvram get wl0_wds)}" -LISTVAL="$FORM_wds" -handle_list "$FORM_wdsremove" "$FORM_wdsadd" "$FORM_wdssubmit" 'mac|FORM_wdsadd|WDS MAC address|required' && { - FORM_wds="$LISTVAL" - save_setting wireless wl0_wds "$FORM_wds" -} -FORM_wdsadd=${FORM_wdsadd:-00:00:00:00:00:00} - CC=${wl0_country_code:-$(nvram get wl0_country_code)} case "$CC" in All|all|ALL) CHANNELS="1 2 3 4 5 6 7 8 9 10 11 12 13 14"; CHANNEL_MAX=14 ;; @@ -22,7 +14,6 @@ for ch in $CHANNELS; do " done - if empty "$FORM_submit"; then FORM_mode=${wl0_mode:-$(nvram get wl0_mode)} infra=${wl0_infra:-$(nvram get wl0_infra)} @@ -102,21 +93,25 @@ if empty "$FORM_submit"; then else SAVED=1 case "$FORM_encryption" in - wpa) V_RADIUS="required";; + wpa) V_RADIUS=" +string|FORM_radius_key|RADIUS server key|min=4 max=63 required|$FORM_radius_key +ip|FORM_radius_ipaddr|RADIUS IP address|required|$FORM_radius_ipaddr";; psk) V_PSK="wpapsk|FORM_wpa_psk|WPA pre-shared key|required|$FORM_wpa_psk";; + wep) V_WEP=" +int|FORM_key|WEP key number|min=1 max=4|$FORM_key +wep|FORM_key1|WEP key 1||$FORM_key1 +wep|FORM_key2|WEP key 2||$FORM_key2 +wep|FORM_key3|WEP key 3||$FORM_key3 +wep|FORM_key4|WEP key 4||$FORM_key4";; esac validate < radio|key|$FORM_key|4 text|key4|$FORM_key4|
end_form -start_form|WDS connections -listedit|wds|$SCRIPT_NAME?|$FORM_wds|$FORM_wdsadd -helpitem|Note -helptext|You should save your settings on this page before adding/removing WDS links -end_form EOF footer ?> diff --git a/openwrt/package/webif/files/www/webif.js b/openwrt/package/webif/files/www/webif.js index e906f8a856..8bdef4dd66 100644 --- a/openwrt/package/webif/files/www/webif.js +++ b/openwrt/package/webif/files/www/webif.js @@ -1,3 +1,8 @@ +function value(name) +{ + var item = document.getElementById(name); + return (item ? item.value : ""); +} function checked(name) { var item = document.getElementById(name); -- 2.30.2